package com.mycompany.app.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.Transient;

import org.springframework.security.core.GrantedAuthority;

@Entity
@Table(name="Perfil")
public class Perfil implements GrantedAuthority {
	 /**
	 * 
	 */
	private static final long serialVersionUID = 9054459962082819498L;
	private int id;
	 private String name;
	 private User user;
	 
	  @Id
	    @GeneratedValue(strategy = GenerationType.IDENTITY)
	    @Column(name="ID", unique = true, nullable = false)
	    public int getId() {
	        return id;
	    }
	 
	    /**
	     * Set User Id
	     *
	     * @param int - User Id
	     */
	    public void setId(int id) {
	        this.id = id;
	    }
	 
	    /**
	     * Get User Name
	     *
	     * @return String - User Name
	     */
	    @Column(name="NAME", nullable = false,length=50)
	    public String getName() {
	        return name;
	    }
	 
	    /**
	     * Set User Name
	     *
	     * @param String - User Name
	     */
	    public void setName(String name) {
	        this.name = name;
	    }

	    @ManyToOne
	    @JoinColumn(name="USER_ID", nullable=false)
		public User getUser() {
			return user;
		}

		public void setUser(User user) {
			this.user = user;
		}
        
		@Transient
		public String getAuthority() {
			return name;
		}
	 
	    

}
